import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../common.dart';

class SnapUp extends StatefulWidget {
  SnapUp({super.key});
  @override
  State<SnapUp> createState() => _QGRulePageState();
}

class _QGRulePageState extends State<SnapUp> {
  bool value = false;
  var items = [
    {"check": '0'},
    {"check": '0'},
    {"check": '0'},
    {"check": '0'},
    {"check": '0'},
    {"check": '0'},
    {"check": '0'},
  ];

  @override
  Widget build(BuildContext context) {
    final totalw = MediaQuery.of(context).size.width / 3 - 20;

    return Scaffold(
      appBar: AppBar(
        backgroundColor: Color(0XFFFFFFFF),
        centerTitle: true,
        title: wText(text: '智能抢购', bold: true, size: 18),
        leading: buildBackButton(context),
      ),
      bottomNavigationBar: wCon(
        text: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [wText(text: '立即抢购', color: 'ffffff', size: 18)],
        ),
        click: () {
          Get.bottomSheet(
            isScrollControlled: true,
            Container(
              padding: EdgeInsets.only(top: 15),
              height: 500,
              decoration: BoxDecoration(
                color: Color(0XFFFFFFFF),
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(10),
                  topRight: Radius.circular(10),
                ),
              ),
              child: Padding(
                padding: EdgeInsets.symmetric(horizontal: 15),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      padding: EdgeInsets.symmetric(
                        horizontal: 12,
                        vertical: 12,
                      ),
                      decoration: BoxDecoration(
                        color: Color(0XFF542AFF),
                        borderRadius: BorderRadius.circular(10),
                      ),
                      child: Row(
                        children: [
                          wImage(url: 'yee', width: 33),
                          SizedBox(width: 5),
                          Column(
                            children: [
                              wText(text: '可用余额', color: 'FFFFFF'),
                              wText(
                                text: '99123',
                                color: 'FFFFFF',
                                size: 15,
                                bold: true,
                              ),
                            ],
                          ),
                          Expanded(child: SizedBox()),
                          Container(
                            width: 50,
                            height: 24,
                            alignment: Alignment.center,
                            decoration: BoxDecoration(
                              color: Color(0XFFFFFFFF),
                              borderRadius: BorderRadius.circular(10),
                            ),
                            child: wText(
                              text: '充值',
                              size: 14,
                              color: '542AFF',
                              bold: true,
                            ),
                          ),
                        ],
                      ),
                    ),
                    SizedBox(height: 20),
                    Expanded(child: 
                      ListView(
                        children: [
                           wText(text: '购买记录', size: 18, bold: true),
                    SizedBox(height: 20),
                    Column(
                      children: [
                        Row(
                          children: [
                            wImage(url: 'jindu', width: 9),
                            SizedBox(width: 10),
                            wText(text: '23:22:33', bold: true),
                          ],
                        ),
                        SizedBox(height: 2),
                        Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Container(
                              margin: EdgeInsets.only(left: 3),
                              height: 56,
                              width: 1,
                              decoration: BoxDecoration(
                                border: Border(
                                  left: BorderSide(color: Color(0XFF6828FF)),
                                ),
                              ),
                            ),
                            SizedBox(width: 13),
                            wText(text: '已购买藏品《200m² 3D艺术展厅》'),
                          ],
                        ),
                      ],
                    ),
                    Column(
                      children: [
                        Row(
                          children: [
                            wImage(url: 'jindu', width: 9),
                            SizedBox(width: 10),
                            wText(text: '23:22:33', bold: true),
                          ],
                        ),
                        SizedBox(height: 2),
                        Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Container(
                              margin: EdgeInsets.only(left: 3),
                              height: 56,
                              width: 1,
                              decoration: BoxDecoration(
                                border: Border(
                                  left: BorderSide(color: Color(0XFF6828FF)),
                                ),
                              ),
                            ),
                            SizedBox(width: 13),
                            wText(text: '已购买藏品《200m² 3D艺术展厅》'),
                          ],
                        ),
                      ],
                    ),
                        ],
                      )
                    ),
                    wCon(text: 
                    Row(
                      children: [
                        wText(text: '抢购中...（点击停止）',color: 'FFFFFF',size: 18)
                      ],
                    )
                    )
                   
                  ],
                ),
              ),
            ),
          );
        },
      ),
      body: ListView(
        padding: EdgeInsets.symmetric(horizontal: 15),
        children: [
          Container(
            padding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
            decoration: BoxDecoration(
              color: Color(0XFF542AFF),
              borderRadius: BorderRadius.circular(10),
            ),
            child: Row(
              children: [
                wImage(url: 'yee', width: 33),
                SizedBox(width: 5),
                Column(
                  children: [
                    wText(text: '可用余额', color: 'FFFFFF'),
                    wText(text: '99123', color: 'FFFFFF', size: 15, bold: true),
                  ],
                ),
                Expanded(child: SizedBox()),
                Container(
                  width: 50,
                  height: 24,
                  alignment: Alignment.center,
                  decoration: BoxDecoration(
                    color: Color(0XFFFFFFFF),
                    borderRadius: BorderRadius.circular(10),
                  ),
                  child: wText(
                    text: '充值',
                    size: 14,
                    color: '542AFF',
                    bold: true,
                  ),
                ),
              ],
            ),
          ),
          SizedBox(height: 10),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              wText(text: '选择想要购买的藏品', size: 14, bold: true),
              Row(
                children: [
                  wText(text: '已选21/23'),
                  Checkbox(
                    splashRadius: 5,
                    activeColor: Color(0XFF6828FF),
                    value: value,
                    onChanged: (val) {
                      value = val!;
                      setState(() {});
                    },
                  ),
                ],
              ),
            ],
          ),
          SizedBox(height: 10),

          Container(
            height: 310,
            child: ListView(
              children: [
                Wrap(
                  spacing: 10,
                  runSpacing: 10,
                  children: List.generate(items.length, (index) {
                    return GestureDetector(
                      onTap: () {
                        if (items[index]['check'] == '1') {
                          items[index]['check'] = '0';
                        } else {
                          items[index]['check'] = '1';
                        }
                        setState(() {});
                      },
                      child: Container(
                        width: totalw,
                        child: Column(
                          children: [
                            Container(
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(10),
                                border: Border.all(
                                  width: 3,
                                  color: Color(
                                    items[index]['check'] == '1'
                                        ? 0XFF6828FF
                                        : 0xffffffff,
                                  ),
                                ),
                              ),
                              width: totalw,
                              height: totalw,
                              child: Stack(
                                children: [
                                  wImage(
                                    url: 'aaa',
                                    width: totalw,
                                    height: totalw,
                                    borderRadius: 10,
                                  ),
                                  if (items[index]['check'] == '1')
                                    Positioned(
                                      top: 10,
                                      left: 10,
                                      child: wImage(url: 'zyuans', width: 16),
                                    ),
                                ],
                              ),
                            ),
                            Container(
                              width: totalw,
                              child: Text(
                                '200m² 3D艺术展厅展厅',
                                style: TextStyle(
                                  fontSize: 12,
                                  overflow: TextOverflow.ellipsis,
                                ),
                                maxLines: 1,
                              ),
                            ),
                            Row(
                              children: [
                                wText(text: '￥'),
                                wText(text: '99.00', bold: true, size: 14),
                              ],
                            ),
                          ],
                        ),
                      ),
                    );
                  }),
                ),
              ],
            ),
          ),
          Container(
            padding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
            decoration: BoxDecoration(
              color: Color(0XFFF8F9FD),
              borderRadius: BorderRadius.circular(10),
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                wText(text: '购买记录', size: 18, bold: true),
                SizedBox(height: 20),
                Column(
                  children: [
                    Row(
                      children: [
                        wImage(url: 'jindu', width: 9),
                        SizedBox(width: 10),
                        wText(text: '23:22:33', bold: true),
                      ],
                    ),
                    SizedBox(height: 2),
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          margin: EdgeInsets.only(left: 3),
                          height: 56,
                          width: 1,
                          decoration: BoxDecoration(
                            border: Border(
                              left: BorderSide(color: Color(0XFF6828FF)),
                            ),
                          ),
                        ),
                        SizedBox(width: 13),
                        wText(text: '已购买藏品《200m² 3D艺术展厅》'),
                      ],
                    ),
                  ],
                ),
                Column(
                  children: [
                    Row(
                      children: [
                        wImage(url: 'jindu', width: 9),
                        SizedBox(width: 10),
                        wText(text: '23:22:33', bold: true),
                      ],
                    ),
                    SizedBox(height: 2),
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          margin: EdgeInsets.only(left: 3),
                          height: 56,
                          width: 1,
                          decoration: BoxDecoration(
                            border: Border(
                              left: BorderSide(color: Color(0XFF6828FF)),
                            ),
                          ),
                        ),
                        SizedBox(width: 13),
                        wText(text: '已购买藏品《200m² 3D艺术展厅》'),
                      ],
                    ),
                  ],
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
